home *** CD-ROM | disk | FTP | other *** search
- Path: news.uh.edu!cosc19z5
- From: cosc19z5@Bayou.UH.EDU (Spasmo)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: Re: Q: '\n' character
- Followup-To: comp.lang.c,comp.unix.programmer
- Date: 13 Apr 1996 23:24:00 GMT
- Organization: University of Houston
- Message-ID: <4kpd2g$eeb@masala.cc.uh.edu>
- References: <4kj66f$k0o@ren.cei.net> <1996Apr11.192937.25676@sq.com> <829396473snz@genesis.demon.co.uk>
- NNTP-Posting-Host: bayou.uh.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Lawrence Kirby (fred@genesis.demon.co.uk) wrote:
- : In article <1996Apr11.192937.25676@sq.com> msb@sq.com "Mark Brader" writes:
-
- [Snip]
-
-
- : >In the specific case of a string obtained from fgets(), we can be
- : >sure that if there is a newline then it is the last character.
- : >This leads to the alternative approach:
- : >
- : > ptr = strchr (buffer, '\n'); /* or strrchr() */
- : > if (ptr) *ptr = '\0';
-
- Ok, I've got a question at this point. Is it really proper to say
- if (ptr)? From what I've read, NULL wasn't supposed to be guaranteed
- to work with true/false tests like the above, so the only safe way
- was if (ptr != NULL). As a matter of fact, that's what Stroustrup
- mentioned in his C++ book as a reason for using 0 instead of the NULL
- pointer when using C++, so that true/false tests could be safely performed.
-
- If I'm wrong please tell me since I've been sticking with ptr != NULL
- now for the very reason of safety. I would love to go for a good old
- true/false test rather than a NULL comparison if in fact this is
- valid regardless of implementation. I've learned to stay away from
- testing code and going with the results since different implementations
- have different behaviors at times so even if my own experience would
- have shown the true/false approach to work I still would have avoided
- it until I heard an official "yes it can be done, or no it can't".
-
- [Snip]
-
- : --
- : -----------------------------------------
- : Lawrence Kirby | fred@genesis.demon.co.uk
- : Wilts, England | 70734.126@compuserve.com
- : -----------------------------------------
-
-
- Thanks.
-
-
- --
-
- .A. G-Force! 1 AM Houston Time
- AAAAA On the Cartoon Network!
- AAY:YAA
- A':::`A This informative message was
- ::::::: brought to you by Spasmo.
- ::( )::
- :::::::
- :::::::
- :::::::
- :::::::
- .A. .do:::::::::::bo. .A.
- AAA .:::::::::::::::::::::. AAA
- d:::::::::::::::::::::::::::::::::::::::::::b
- Y:::::::::::::::::::::::::::::::::::::::::::Y
- `YjY `:::::::|::|::|:::::::' YjY'
- `::|::|::|::'
- |
-